﻿@using EntityModel
@model EntityModel.ProductAlbum
@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <title>Index</title>
    <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
</head>
<body>
    <script src="@Url.Content("~/Scripts/jquery-1.4.4.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.form.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.fileupload.js")" type="text/javascript"></script>
    <fieldset>
        <legend>商品相册管理</legend>
        <div class="editor-label">
            商品名称:@ViewData["Name"]
        </div>
        <div class="editor-label">
            图片列表
        </div>
        <div class="editor-field">
            <div style="width: 100%; border: solid 1px #dddddd; float: left; height: 230px;">
                @{ var list = ViewData["AlbumList"]
    as IEnumerable<ProductAlbum>;}
                @foreach (ProductAlbum ab in list)
                { 
                    <div style="white-space: 200px; height: 200px; float: left; margin-left: 15px; margin-top: 10px;">
                        <a href="/ProductAlbum/Delete?id=@ab.Id&pid=@ab.PruductId">
                            <img title="双击图片可删除图片" height="189px" width="189px" src="http://img.youlanye.com/product/@ab.Url" /></a><br />
                        <div style="width: 180px; margin-left: auto; margin-right: auto; text-align: center;">
                            @if (ab.Product.AlbumId == ab.Id)
                            { <a href="" style="color: Green">封面</a>}
                            else
                            {<a href="/ProductAlbum/IsHome?pid=@ab.PruductId&id=@ab.Id">设为封面</a>}
                        </div>
                    </div>
                }
            </div>
        </div>
        @using (Html.BeginForm("Create", "ProductAlbum", FormMethod.Post, new { enctype = "multipart/form-data" }))
        {
            <div class="editor-field">
                <div style="width: 100%; border: solid 1px #dddddd; float: left;">
                    <div class="fileimgdiv" style="clear: both; margin-bottom: 5px;">
                        @Html.HiddenFor(model => model.Url, new { @class = "required" })
                        <input id="PruductId" name="PruductId" type="hidden" value="@ViewData["PruductId"]"/>
                    </div>
                    <span>
                        <input type="file" name="file" height="189px" width="189px" />
                    </span>
                    <input type="button" value="upload" onclick="javascript:uploadfile(this);" />&nbsp;<span>图片最适合宽度
                        175px × 228px</span>
                </div>
            </div>
      
            <p>
                <input type="submit" value="Create" />
            </p>  }
    </fieldset>
    <div>
        <a href="/Product/Index">返回商品列表</a>
    </div>
</body>
</html>
